<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<input id="single_file" name="upfile" type="file" />
<input id="multiple_files" name="upfile[]" multiple="multiple" type="file" />
<input id="single_or_multiple_file" name="upfile[]" type="file" />
<p>This tests the label of a file chooser button.</p>
<div id="console"></div>
<script>
function uploadButton(input) {
  return internals.shadowRoot(input).getElementById('file-upload-button');
}

if (window.testRunner) {
    var file = document.getElementById('single_file');
    var button = uploadButton(file);
    var label = button.getAttribute('value');
    var result = 'The label of a single file chooser button is "' + label + '".';
    label == 'Choose File' ? testPassed(result) : testFailed(result);

    file = document.getElementById('multiple_files');
    button = uploadButton(file);
    label = button.getAttribute('value');
    result = 'The label of a multiple file chooser button is "' + label + '".';
    label == 'Choose Files' ? testPassed(result) : testFailed(result);

    file = document.getElementById('single_or_multiple_file');
    button = uploadButton(file);
    label = button.getAttribute('value');
    result = 'Initially, the label of a file chooser button is "' + label + '".';
    label == 'Choose File' ? testPassed(result) : testFailed(result);

    file.setAttribute("multiple", "multiple");
    button = uploadButton(file);
    label = button.getAttribute('value');
    result = 'Set "multiple" attribute, then the label of the file chooser button becomes "' + label + '".';
    label == 'Choose Files' ? testPassed(result) : testFailed(result);

    file.removeAttribute("multiple");
    button = uploadButton(file);
    label = button.getAttribute('value');
    result = 'Unset "multiple" attribute, then the label of the file chooser button becomes "' + label + '".';
    label == 'Choose File' ? testPassed(result) : testFailed(result);
}
</script>
</body>
</html>
